#include <iostream>

using namespace std;
#define MAX_SIZE    100

void
heap_insert(int heap[], int size, int num) ;
main() {
    int input [MAX_SIZE] = {0};
    int heap [MAX_SIZE] = {0};
    int items = 0;
    cin >>items;
    
    for (int i = 0; i < items; i++) {
        cin >> input [i];
        heap_insert(heap, i, input [i]);
    }
    
    for (int i = 0; i < items; i++) {
        cout << heap [i] << ends;
    }



     
    return 0;
}

void
heap_insert(int heap[], int size, int num) {
    if (size != 0) {
        heap [size] = num;

        int parent  = size;
        int current = size;

        while (parent != 0) {
            parent  = (current + 1)/2 - 1;
            if (heap [parent] < heap [current]) {
                int temp    = heap [parent];
                heap [parent]   = heap [current];
                heap [current]  = temp;

                current = parent;
            }
            else {
                break;
            }
        }
    }
    else {
        cout << "Heap 0: " << num << endl;
        heap [0]    = num;    
    }
}
